package homework;

import java.util.Scanner;

public class StringReverse {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入字符串：");
        String input = sc.nextLine();

        // 字符串反转
        String reversed = new StringBuilder(input).reverse().toString();
        System.out.println("反转结果:" + reversed);

        // 统计字符类型
        int letters = 0, digits = 0, others = 0;
        for (char c : input.toCharArray()) {
            if (Character.isLetter(c)) letters++;
            else if (Character.isDigit(c)) digits++;
            else others++;
        }
        System.out.printf("字母: %d, 数字: %d, 其他: %d", letters, digits, others);
    }
}
